package com.itcast.admin.controller;


import com.itcast.admin.domain.request.CreateSetmealCategoryReqDTO;
import com.itcast.admin.domain.request.SetmealCategoryPagerReqDTO;
import com.itcast.admin.domain.response.SetmealCategoryListResDTO;
import com.itcast.admin.domain.response.SetmealCategoryPagerResDTO;
import com.itcast.admin.service.ISetmealCategoryService;
import com.jzo2o.common.model.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 套餐类型表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-05
 */
@RestController
@RequestMapping("/admin/setmeal-category")
@Api(tags = "套餐类型相关接口")
public class SetmealCategoryController {

    @Autowired
    private ISetmealCategoryService setmealCategoryService;

    @GetMapping("/pageQuery")
    @ApiOperation("获取套餐类型列表")
    public PageResult<SetmealCategoryPagerResDTO> pageQuery(SetmealCategoryPagerReqDTO setmealCategoryPagerReqDTO) {
        return setmealCategoryService.pageQuery(setmealCategoryPagerReqDTO);
    }
    @PostMapping
    @ApiOperation("新增套餐类型")
    public void createSetmealCateGory(@RequestBody CreateSetmealCategoryReqDTO createSetmealCategoryReqDTO) {
        setmealCategoryService.createSetmealCateGory(createSetmealCategoryReqDTO);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id获取套餐类型")
    public SetmealCategoryPagerResDTO getSetmealCateGoryById(@PathVariable Integer id) {
        return setmealCategoryService.getSetmealCateGoryById(id);
    }
    @PutMapping("/{id}")
    @ApiOperation("根据id修改套餐类型")
    public void updateSetmealCateGoryById(@PathVariable Integer id,@RequestBody CreateSetmealCategoryReqDTO createSetmealCategoryReqDTO) {
        setmealCategoryService.updateSetmealCateGoryById(id,createSetmealCategoryReqDTO);
    }
    @PutMapping("/enable/{id}")
    @ApiOperation("根据id开启套餐类型")
    public void enableSetmealCateGoryById(@PathVariable Integer id) {
        setmealCategoryService.enableSetmealCateGoryById(id);
    }

    @GetMapping("/checkDisable/{id}")
    @ApiOperation("校验套餐类型是否可以禁用")
    public String checkDisableById(@PathVariable Integer id) {
        return setmealCategoryService.checkDisableById(id);
    }

    @PutMapping("/disable/{id}")
    @ApiOperation("根据id禁用套餐类型")
    public void disableSetmealCateGoryById(@PathVariable Integer id) {
        setmealCategoryService.disableSetmealCateGoryById(id);
    }
    @DeleteMapping("/{id}")
    @ApiOperation("根据id删除套餐类型")
    public void deleteSetmealCateGoryById(@PathVariable Integer id) {
        setmealCategoryService.deleteSetmealCateGoryById(id);
    }
    @GetMapping("/listForFilter")
    @ApiOperation("定案类型下拉列表")
    public List<SetmealCategoryListResDTO> listForFilter(Integer setmealCategoryStatus) {
        return setmealCategoryService.listForFilter(setmealCategoryStatus);
    }
}
